using System;

namespace Graphix
{
    public class ChartBorder
    {
        private float _top;
        private float _bottom;
        private float _left;
        private float _right;

        public float Top
        {
            get { return _top; }
            set
            {
                _top = value;
                OnChange();
            }
        }

        public float Bottom
        {
            get { return _bottom; }
            set
            {
                _bottom = value;
                OnChange();
            }
        }

        public float Left
        {
            get { return _left; }
            set
            {
                _left = value;
                OnChange();
            }
        }

        public float Right
        {
            get { return _right; }
            set
            {
                _right = value;
                OnChange();
            }
        }

        public float Width
        {
            get { return _right - _left; }
        }

        public float Height
        {
            get { return _bottom - _top; }
        }
        public event EventHandler<ChangeEventArgs> Changed;

        private void OnChange()
        {
            if (Changed != null)
            {
                Changed(this, new ChangeEventArgs(Top, Bottom, Left, Right));
            }
        }

        public ChartBorder(float top, float bottom, float left, float right)
        {
            Top = top;
            Bottom = bottom;
            Left = left;
            Right = right;
        }
    }
}